﻿@Html.Extra()
@{
    Layout = "~/Views/Shared/OA/_Index.cshtml";
    var catalog = ViewBag.Catalog as Catalog;
}
@section Toolbar
{
    @Html.MyNet().Button(new ButtonOptions { Text = "审核通过", Power = "CMS_Leaveword_Audit", Click = "pass" })
    @Html.MyNet().Button(new ButtonOptions { Text = "审核不通过", Power = "CMS_Leaveword_Audit", Click = "unPass" })
    @Html.MyNet().Button(new ButtonOptions { Text = "删除", Power = "CMS_Leaveword_Remove", Click = "removee" })
    @Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "back" })
}
@section Menu
{
    @Html.MyNet().Menu(new ButtonOptions { Text = "查看详细", Click="detail" })
    @Html.MyNet().Menu(new ButtonOptions { Text = "回复", Power = "CMS_Leaveword_Audit", Click = "reply" })
    @Html.MyNet().Menu(new ButtonOptions { Text = "审核通过", Power = "CMS_Leaveword_Audit", Click = "pass" })
    @Html.MyNet().Menu(new ButtonOptions { Text = "审核不通过", Power = "CMS_Leaveword_Audit", Click = "unPass" })
    @Html.MyNet().Menu(new ButtonOptions { Text = "删除", Power = "CMS_Leaveword_Remove", Click = "removee" })
}
@section Main
{
    <div id="grid" class="grid">
    </div>
    <div id="pager" class="pager">
    </div>
}
@Html.Hidden("DataId", Request["Id"])
@Html.Hidden("CatalogKey", catalog.Key)
<script>

    var dataId = $("#DataId").val();
    var catalogKey = $("#CatalogKey").val();

    var leavewordUrl = "/CMS/Leaveword/";

    var query = {};
    var pageSize = 20;
    var pageNo = 1;

    jQuery(function ()
    {
        read();
    });

    function read()
    {
        query.pageSize = pageSize;
        query.pageNo = pageNo;
        query.dataId = dataId;
        query.catalogKey = catalogKey;

        $.ajax
        ({
            url: leavewordUrl + "ReadForData?VPartial=Read",
            data: query,
            type: "post",
            error: disposeError,
            success: function (result)
            {

                if (disposeException(result)) return;
                bind(result);
            }
        });
    }

    function detail()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(leavewordUrl + "Detail?Id=" + gridSelected());
    }

    function reply()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(leavewordUrl + "Reply?LeavewordId=" + gridSelected());
    }

    function removee()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        if (!confirm("确定要删除选中的数据吗？")) return;

        $.ajax
        ({
            url: leavewordUrl + "Remove",
            data: { ids: gridSelected() },
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;

                read();
            }
        });
    }

    function pass()
    {
        if (!gridSelected()) return alert("未选中任何数据！");

        $.ajax
        ({
            url: leavewordUrl + "Pass",
            data: { ids: gridSelected() },
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;

                read();
            }
        });
    }

    function unPass()
    {
        if (!gridSelected()) return alert("未选中任何数据！");

        $.ajax
        ({
            url: leavewordUrl + "UnPass",
            data: { ids: gridSelected() },
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;
                read();
            }
        });
    }

</script>
